package com.study.ming.studydemo.thd;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;

public class CountDownLatchDemo2 {
    private static AtomicInteger t = new AtomicInteger();
    static CountDownLatch c = new CountDownLatch(1);

    public static void main(String[] args) throws InterruptedException {
        new Thread() {
            public void run() {
                for (int i = 0; i < 10000; i++) {
                    final int andDecrement = t.getAndDecrement();
                    System.out.print(andDecrement);
                }
                c.countDown();
            }
        }.start();
        c.await();
        for (int i = 0; i < 10000; i++) {
            final int andIncrement = t.getAndIncrement();
            System.out.println(andIncrement);
        }
        System.out.println(t.get());
    }

}